﻿using System;
using System.Web.UI.WebControls;
using System.Collections;
using WorkOrder.Business;
using System.Data;
using ZedGraph;
using ZedGraph.Web;
using System.Drawing;

namespace WorkOrder
{
    public partial class queryOrder : System.Web.UI.Page
    {
        private DataTable dt;
        private DataTable dt2;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null || Session["UserID"].ToString() == "")
            {
                Session.Clear();
                ClientScript.RegisterClientScriptBlock(GetType(), "windowhref", "<script type='text/javascript'>alert('对不起，您还没有登录系统！');window.parent.location.href='../login.aspx';</script>");
            }
            if (!Page.IsPostBack)
            {
                #region 页面显示设置
                hidTitle.Value = "";
                string a = Request.Params["a"];
                ZedGraphWeb1.Visible = false;
                ZedGraphWeb2.Visible = false;
                switch (a)
                {
                    case "1":
                        Label1.Text = "统计某时段内某区域的每个产品类型的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = true;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlArea.Items.Clear();
                        ddlArea.DataTextField = "area_name";
                        ddlArea.DataValueField = "area_id";
                        ddlArea.DataSource = new Business_Table_Work_order().GetArea();
                        ddlArea.DataBind();
                        ddlArea.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlArea.SelectedIndex = ddlArea.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "2":
                        Label1.Text = "统计某时段内某区域的每个业务类型的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = true;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlArea.Items.Clear();
                        ddlArea.DataTextField = "area_name";
                        ddlArea.DataValueField = "area_id";
                        ddlArea.DataSource = new Business_Table_Work_order().GetArea();
                        ddlArea.DataBind();
                        ddlArea.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlArea.SelectedIndex = ddlArea.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "3":
                        Label1.Text = "统计某时段内某区域的当前每个工单状态的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = true;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlArea.Items.Clear();
                        ddlArea.DataTextField = "area_name";
                        ddlArea.DataValueField = "area_id";
                        ddlArea.DataSource = new Business_Table_Work_order().GetArea();
                        ddlArea.DataBind();
                        ddlArea.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlArea.SelectedIndex = ddlArea.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "6":
                        Label1.Text = "统计某时段内某镇区的每个产品类型的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = true;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlTown.Items.Clear();
                        ddlTown.DataTextField = "town_name";
                        ddlTown.DataValueField = "town_id";
                        ddlTown.DataSource = new Business_Table_Work_order().GetTown();
                        ddlTown.DataBind();
                        ddlTown.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlTown.SelectedIndex = ddlTown.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "7":
                        Label1.Text = "统计某时段内某镇区的每个业务类型的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = true;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlTown.Items.Clear();
                        ddlTown.DataTextField = "town_name";
                        ddlTown.DataValueField = "town_id";
                        ddlTown.DataSource = new Business_Table_Work_order().GetTown();
                        ddlTown.DataBind();
                        ddlTown.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlTown.SelectedIndex = ddlTown.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "8":
                        Label1.Text = "统计某时段内某镇区的当前每个工单状态的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = true;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlTown.Items.Clear();
                        ddlTown.DataTextField = "town_name";
                        ddlTown.DataValueField = "town_id";
                        ddlTown.DataSource = new Business_Table_Work_order().GetTown();
                        ddlTown.DataBind();
                        ddlTown.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlTown.SelectedIndex = ddlTown.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "11":
                        Label1.Text = "按时间周期统计某时段内某区域的工单数量";
                        Panel1.Visible = true;
                        palArea.Visible = true;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlArea.Items.Clear();
                        ddlArea.DataTextField = "area_name";
                        ddlArea.DataValueField = "area_id";
                        ddlArea.DataSource = new Business_Table_Work_order().GetArea();
                        ddlArea.DataBind();
                        ddlArea.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlArea.SelectedIndex = ddlArea.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "12":
                        Label1.Text = "按时间周期统计某时段内某镇区的工单数量";
                        Panel1.Visible = true;
                        palArea.Visible = false;
                        palTown.Visible = true;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlTown.Items.Clear();
                        ddlTown.DataTextField = "town_name";
                        ddlTown.DataValueField = "town_id";
                        ddlTown.DataSource = new Business_Table_Work_order().GetTown();
                        ddlTown.DataBind();
                        ddlTown.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlTown.SelectedIndex = ddlTown.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "13":
                        Label1.Text = "按时间周期统计某时段内某业务类型的工单数量";
                        Panel1.Visible = true;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = true;
                        palOrderState.Visible = false;
                        ddlOrderType.Items.Clear();
                        ddlOrderType.DataTextField = "order_type";
                        ddlOrderType.DataValueField = "order_type_id";
                        ddlOrderType.DataSource = new Business_Table_Work_order().GetOrderType();
                        ddlOrderType.DataBind();
                        ddlOrderType.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlOrderType.SelectedIndex = ddlOrderType.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "14":
                        Label1.Text = "按时间周期统计某时段内某产品类型的工单数量";
                        Panel1.Visible = true;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = true;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlProduct.Items.Clear();
                        ddlProduct.DataTextField = "product_name";
                        ddlProduct.DataValueField = "product_id";
                        ddlProduct.DataSource = new Business_Table_Work_order().GetProduct();
                        ddlProduct.DataBind();
                        ddlProduct.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlProduct.SelectedIndex = ddlProduct.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "15":
                        Label1.Text = "统计某时段内某工单状态的每个区域的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = true;
                        palChild.Visible = false;
                        ddlOrderState.Items.Clear();
                        ddlOrderState.DataTextField = "order_status";
                        ddlOrderState.DataValueField = "order_status";
                        ddlOrderState.DataSource = new Business_Table_Work_order().GetOrderStatus();
                        ddlOrderState.DataBind();
                        ddlOrderState.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlOrderState.SelectedIndex = ddlOrderState.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "19":
                        Label1.Text = "统计某时段内某业务类型的每个区域的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = true;
                        palOrderState.Visible = false;
                        ddlOrderType.Items.Clear();
                        ddlOrderType.DataTextField = "order_type";
                        ddlOrderType.DataValueField = "order_type_id";
                        ddlOrderType.DataSource = new Business_Table_Work_order().GetOrderType();
                        ddlOrderType.DataBind();
                        ddlOrderType.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlOrderType.SelectedIndex = ddlOrderType.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "20":
                        Label1.Text = "统计某时段内某业务类型的每个镇区的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = true;
                        palOrderState.Visible = false;
                        ddlOrderType.Items.Clear();
                        ddlOrderType.DataTextField = "order_type";
                        ddlOrderType.DataValueField = "order_type_id";
                        ddlOrderType.DataSource = new Business_Table_Work_order().GetOrderType();
                        ddlOrderType.DataBind();
                        ddlOrderType.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlOrderType.SelectedIndex = ddlOrderType.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "22":
                        Label1.Text = "统计某时段内某产品类型的每个区域的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = true;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlProduct.Items.Clear();
                        ddlProduct.DataTextField = "product_name";
                        ddlProduct.DataValueField = "product_id";
                        ddlProduct.DataSource = new Business_Table_Work_order().GetProduct();
                        ddlProduct.DataBind();
                        ddlProduct.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlProduct.SelectedIndex = ddlProduct.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "23":
                        Label1.Text = "统计某时段内某产品类型的每个镇区的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = true;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        ddlProduct.Items.Clear();
                        ddlProduct.DataTextField = "product_name";
                        ddlProduct.DataValueField = "product_id";
                        ddlProduct.DataSource = new Business_Table_Work_order().GetProduct();
                        ddlProduct.DataBind();
                        ddlProduct.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlProduct.SelectedIndex = ddlProduct.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                    case "25":
                        Label1.Text = "统计某时段内每个区域的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        palChild.Visible = false;
                        break;
                    case "26":
                        Label1.Text = "统计某时段内每个镇区的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        palChild.Visible = false;
                        break;
                    case "27":
                        Label1.Text = "统计某时段内每个业务类型的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        palChild.Visible = false;
                        break;
                    case "28":
                        Label1.Text = "统计某时段内每个产品类型的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = false;
                        palChild.Visible = false;
                        break;
                    case "29":
                        Label1.Text = "统计某时段内某工单状态的每个镇区的工单数量";
                        Panel1.Visible = false;
                        palArea.Visible = false;
                        palTown.Visible = false;
                        palProductType.Visible = false;
                        palOrderType.Visible = false;
                        palOrderState.Visible = true;
                        palChild.Visible = false;
                        ddlOrderState.Items.Clear();
                        ddlOrderState.DataTextField = "order_status";
                        ddlOrderState.DataValueField = "order_status";
                        ddlOrderState.DataSource = new Business_Table_Work_order().GetOrderStatus();
                        ddlOrderState.DataBind();
                        ddlOrderState.Items.Add(new ListItem("-- 请选择 --", "0"));
                        ddlOrderState.SelectedIndex = ddlOrderState.Items.Count - 1;
                        palChild.Visible = false;
                        break;
                }
                #endregion
            }
        }

        protected void btnSearch_ServerClick(object sender, EventArgs e)
        {
            string a = Request.Params["a"];
            ArrayList arr;
            string sqlstr = "";
            string tmp = "";
            switch (a)
            {
                #region 1 统计某时段内某区域的每个产品类型的工单数量 子单
                case "1":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlArea.SelectedValue=="0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhef", "<script type='text/javascript'>alert('请选择区域！');</script>");
                        return;
                    }
                    arr = new Business_Table_Work_order().GetTownByArea(ddlArea.SelectedValue);
                    
                    for (int i = 0; i < arr.Count; i++)
                    {
                        tmp += string.Format("town_id={0} or ", ((object[])arr[i])[0]);
                    }
                    if (tmp != "")
                    {
                        tmp = "and (" + tmp.Substring(0, tmp.Length - 4) + ")";
                    }
                    sqlstr = "select A.product_name as 产品类型,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from " +
                                    "(select Table_Work_order.order_id,Table_Work_order.order_number,Table_Product.product_name from Table_Work_order,Table_Product " +
                                    "where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp +
                                    " and Table_Work_order.product_id=Table_Product.product_id ) as A group by A.product_name;select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlArea.SelectedItem.Text + "每个产品类型的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.product_name as 产品类型,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Work_order as B,Table_Product as C where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp + " and A.order_id=B.order_id and B.product_id=C.product_id GROUP BY C.product_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个产品类型的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 2 统计某时段内某区域的每个业务类型的工单数量 子单
                case "2":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlArea.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhef", "<script type='text/javascript'>alert('请选择区域！');</script>");
                        return;
                    }
                    arr = new Business_Table_Work_order().GetTownByArea(ddlArea.SelectedValue);
                    
                    for (int i = 0; i < arr.Count; i++)
                    {
                        tmp += "town_id=" + ((object[])arr[i])[0] + " or ";
                    }
                    if (tmp != "")
                    {
                        tmp = "and (" + tmp.Substring(0, tmp.Length - 4) + ")";
                    }
                    sqlstr = "select A.order_type as 业务类型,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from " +
                                    "(select Table_Work_order.order_id,Table_Work_order.order_number,Table_Order_type.order_type from Table_Work_order,Table_Order_type " +
                                    "where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp +
                                    " and Table_Work_order.order_type_id=Table_Order_type.order_type_id ) as A group by A.order_type;select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlArea.SelectedItem.Text + "每个业务类型的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.order_type as 业务类型,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Work_order as B,Table_Order_type as C where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp + " and A.order_id=B.order_id and B.order_type_id=C.order_type_id GROUP BY C.order_type;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个业务类型的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 6 统计某时段内某镇区的每个产品类型的工单数量 子单
                case "6":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlTown.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhef", "<script type='text/javascript'>alert('请选择镇区！');</script>");
                        return;
                    }
                    sqlstr = "select A.product_name as 产品类型,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from " +
                                    "(select Table_Work_order.order_id,Table_Work_order.order_number,Table_Product.product_name from Table_Work_order,Table_Product " +
                                    "where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and town_id=" + ddlTown.SelectedValue +
                                    " and Table_Work_order.product_id=Table_Product.product_id ) as A group by A.product_name;select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0]; 
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlTown.SelectedItem.Text + "每个产品类型的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.product_name as 产品类型,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Work_order as B,Table_Product as C where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and B.town_id=" + ddlTown.SelectedValue + " and A.order_id=B.order_id and B.product_id=C.product_id GROUP BY C.product_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个产品类型的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 7 统计某时段内某镇区的每个业务类型的工单数量 子单
                case "7": 
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlTown.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhef", "<script type='text/javascript'>alert('请选择镇区！');</script>");
                        return;
                    }
                    sqlstr = "select A.order_type as 业务类型,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from " +
                                    "(select Table_Work_order.order_id,Table_Work_order.order_number,Table_Order_type.order_type from Table_Work_order,Table_Order_type " +
                                    "where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and town_id=" + ddlTown.SelectedValue +
                                    " and Table_Work_order.order_type_id=Table_Order_type.order_type_id ) as A group by A.order_type;select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlTown.SelectedItem.Text + "每个业务类型的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.order_type as 业务类型,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Work_order as B,Table_Order_type as C where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and B.town_id=" + ddlTown.SelectedValue + " and A.order_id=B.order_id and B.order_type_id=C.order_type_id GROUP BY C.order_type;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个业务类型的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 11 按时间周期统计某时段内某区域的工单数量
                case "11":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (!radJi.Checked && !radYue.Checked && !radZhou.Checked && !radRi.Checked)
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhe", "<script type='text/javascript'>alert('请选择一个统计周期！');</script>");
                        return;
                    }
                    if (ddlArea.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhef", "<script type='text/javascript'>alert('请选择区域！');</script>");
                        return;
                    }
                    arr = new Business_Table_Work_order().GetTownByArea(ddlArea.SelectedValue);
                    
                    for (int i = 0; i < arr.Count; i++)
                    {
                        tmp += "town_id=" + ((object[])arr[i])[0] + " or ";
                    }
                    if (tmp != "")
                    {
                        tmp = "and (" + tmp.Substring(0, tmp.Length - 4) + ")";
                    }
                    
                    if (radJi.Checked)
                        sqlstr = "select 季度, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(Q,task_time)+'季度' as 季度,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp + ") T1 group by 季度;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 季度;drop table #T;";
                    else if (radYue.Checked)
                        sqlstr = "select 月份, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(M,task_time)+'月' as 月份,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp + ") T1 group by 月份;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 月份;drop table #T;";
                    else if (radZhou.Checked)
                        sqlstr = "select 星期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年第'+DATENAME(WK,task_time)+'周' as 星期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp + ") T1 group by 星期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 星期;drop table #T;";
                    else if (radRi.Checked)
                        sqlstr = "select 日期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'/'+DATENAME(M,task_time)+'/'+DATENAME(D,task_time) as 日期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' " + tmp + ") T1 group by 日期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 日期;drop table #T;";

                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlArea.SelectedItem.Text + "的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;
                    break;
                #endregion

                #region 12  按时间周期统计某时段内某镇区的工单数量
                case "12":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (!radJi.Checked && !radYue.Checked && !radZhou.Checked && !radRi.Checked)
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhe", "<script type='text/javascript'>alert('请选择一个统计周期！');</script>");
                        return;
                    }
                    if (ddlTown.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择镇区！');</script>");
                        return;
                    }
                    
                    if (radJi.Checked)
                        sqlstr = "select 季度, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(Q,task_time)+'季度' as 季度,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and town_id=" + ddlTown.SelectedValue + ") T1 group by 季度;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 季度;drop table #T;";
                    else if (radYue.Checked)
                        sqlstr = "select 月份, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(M,task_time)+'月' as 月份,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and town_id=" + ddlTown.SelectedValue + ") T1 group by 月份;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 月份;drop table #T;";
                    else if (radZhou.Checked)
                        sqlstr = "select 星期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年第'+DATENAME(WK,task_time)+'周' as 星期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and town_id=" + ddlTown.SelectedValue + ") T1 group by 星期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 星期;drop table #T;";
                    else if (radRi.Checked)
                        sqlstr = "select 日期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'/'+DATENAME(M,task_time)+'/'+DATENAME(D,task_time) as 日期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and town_id=" + ddlTown.SelectedValue + ") T1 group by 日期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 日期;drop table #T;";

                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlTown.SelectedItem.Text + "的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;
                    break;
                #endregion 

                #region 13 按时间周期统计某时段内某业务类型的工单数量
                case "13":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (!radJi.Checked && !radYue.Checked && !radZhou.Checked && !radRi.Checked)
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhe", "<script type='text/javascript'>alert('请选择一个统计周期！');</script>");
                        return;
                    }
                    if (ddlOrderType.SelectedValue == "0")
                    { 
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择业务类型！');</script>");
                        return;
                    }
                    
                    if (radJi.Checked)
                        sqlstr = "select 季度, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(Q,task_time)+'季度' as 季度,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and order_type_id=" + ddlOrderType.SelectedValue + ") T1 group by 季度;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 季度;drop table #T;";
                    else if (radYue.Checked)
                        sqlstr = "select 月份, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(M,task_time)+'月' as 月份,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and order_type_id=" + ddlOrderType.SelectedValue + ") T1 group by 月份;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 月份;drop table #T;";
                    else if (radZhou.Checked)
                        sqlstr = "select 星期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年第'+DATENAME(WK,task_time)+'周' as 星期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and order_type_id=" + ddlOrderType.SelectedValue + ") T1 group by 星期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 星期;drop table #T;";
                    else if (radRi.Checked)
                        sqlstr = "select 日期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'/'+DATENAME(M,task_time)+'/'+DATENAME(D,task_time) as 日期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and order_type_id=" + ddlOrderType.SelectedValue + ") T1 group by 日期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 日期;drop table #T;";

                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlOrderType.SelectedItem.Text + "的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;
                    break;
                #endregion

                #region 14 按时间周期统计某时段内某产品类型的工单数量
                case "14":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (!radJi.Checked && !radYue.Checked && !radZhou.Checked && !radRi.Checked)
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhe", "<script type='text/javascript'>alert('请选择一个统计周期！');</script>");
                        return;
                    }
                    if (ddlProduct.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择产品类型！');</script>");
                        return;
                    }
                    
                    if (radJi.Checked)
                        sqlstr = "select 季度, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(Q,task_time)+'季度' as 季度,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and product_id=" + ddlProduct.SelectedValue + ") T1 group by 季度;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 季度;drop table #T;";
                    else if (radYue.Checked)
                        sqlstr = "select 月份, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年'+DATENAME(M,task_time)+'月' as 月份,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and product_id=" + ddlProduct.SelectedValue + ") T1 group by 月份;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 月份;drop table #T;";
                    else if (radZhou.Checked)
                        sqlstr = "select 星期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'年第'+DATENAME(WK,task_time)+'周' as 星期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and product_id=" + ddlProduct.SelectedValue + ") T1 group by 星期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 星期;drop table #T;";
                    else if (radRi.Checked)
                        sqlstr = "select 日期, count(cast(order_id as varchar(40))) as 工单数量 into #T from (select DATENAME(YYYY,task_time)+'/'+DATENAME(M,task_time)+'/'+DATENAME(D,task_time) as 日期,order_id" +
                                 " from Table_Work_order where task_time between '" + txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and product_id=" + ddlProduct.SelectedValue + ") T1 group by 日期;" +
                                 "select * from #T union select '合计',SUM(工单数量) from #T order by 日期;drop table #T;";

                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlProduct.SelectedItem.Text + "的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;
                    break;
                #endregion

                #region 15 统计某时段内某工单状态的每个区域的工单数量
                case "15":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhr", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlOrderState.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择工单状态！');</script>");
                        return;
                    }
                    sqlstr = "select B.area_name as 区域,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Area as B where A.order_status='" + ddlOrderState.SelectedValue + "' and A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.area_id=B.area_id GROUP BY B.area_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个区域的" + ddlOrderState.SelectedItem.Text + "工单的数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;
                    palChild.Visible = false;
                    break;
                #endregion

                #region 19 统计某时段内某业务类型的每个区域的工单数量 子单
                case "19":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlOrderType.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择业务类型！');</script>");
                        return;
                    }
                    sqlstr = "select C.area_name as 区域,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Area as C where order_type_id=" + ddlOrderType.SelectedValue + " and A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.area_id=C.area_id GROUP BY C.area_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个区域的" + ddlOrderType.SelectedItem.Text + "单的子单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select E.area_name as 区域,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Work_order as B,Table_Area as E where order_type_id=" + ddlOrderType.SelectedValue + " and A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.area_id=E.area_id GROUP BY E.area_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个区域的" + ddlOrderType.SelectedItem.Text + "单的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 20 统计某时段内某业务类型的每个镇区的工单数量 子单
                case "20":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlOrderType.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择业务类型！');</script>");
                        return;
                    }
                    sqlstr = "select B.town_name as 镇区,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Town as B where order_type_id=" + ddlOrderType.SelectedValue + " and A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.town_id=B.town_id GROUP BY B.town_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的" + ddlOrderType.SelectedItem.Text + "单的子单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.town_name as 镇区,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Town as C,Table_Work_order as B where order_type_id=" + ddlOrderType.SelectedValue + " and A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.town_id=C.town_id GROUP BY C.town_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的" + ddlOrderType.SelectedItem.Text + "单的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 22 统计某时段内某产品类型的每个区域的工单数量 子单
                case "22":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlProduct.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择业务类型！');</script>");
                        return;
                    }
                    sqlstr = "select C.area_name as 区域,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Town as B,Table_Area as C where product_id=" + ddlProduct.SelectedValue + " and A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.town_id=B.town_id and B.area_id=C.area_id GROUP BY C.area_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " " + ddlProduct.SelectedItem.Text + "每个区域的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select E.area_name as 区域,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Town as C,Table_Work_order as B,Table_Area as E where product_id=" + ddlProduct.SelectedValue + " and A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.town_id=C.town_id and C.area_id=E.area_id GROUP BY E.area_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个区域的" + ddlProduct.SelectedItem.Text + "子单的数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 23 统计某时段内某产品类型的每个镇区的工单数量 子单
                case "23":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlProduct.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择业务类型！');</script>");
                        return;
                    }
                    sqlstr = "select B.town_name as 镇区,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Town as B where product_id=" + ddlProduct.SelectedValue + " and A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.town_id=B.town_id GROUP BY B.town_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的" + ddlProduct.SelectedItem.Text + "工单的数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.town_name as 镇区,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Town as C,Table_Work_order as B where product_id=" + ddlProduct.SelectedValue + " and A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.town_id=C.town_id GROUP BY C.town_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的" + ddlProduct.SelectedItem.Text + "子单的数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 25 统计某时段内每个区域的工单数量 子单
                case "25":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    sqlstr = "select C.area_name as 区域,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Town as B,Table_Area as C where A.task_time between '" + 
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.town_id=B.town_id and B.area_id=C.area_id GROUP BY C.area_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个区域的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select E.area_name as 区域,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Work_order as B,Table_Area as E where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.area_id=E.area_id GROUP BY E.area_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个区域的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 26 统计某时段内每个镇区的工单数量 子单
                case "26":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    sqlstr = "select B.town_name as 镇区,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Town as B where A.task_time between '" + 
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.town_id=B.town_id GROUP BY B.town_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.town_name as 镇区,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Town as C,Table_Work_order as B where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.town_id=C.town_id GROUP BY C.town_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 27 统计某时段内每个业务类型的工单数量 子单
                case "27":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    sqlstr = "select B.order_type as 业务类型,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Order_type as B where A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_type_id=B.order_type_id GROUP BY B.order_type;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个业务类型的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.order_type as 产品类型,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Order_type as C,Table_Work_order as B where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.order_type_id=C.order_type_id GROUP BY C.order_type;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个业务类型的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 28 统计某时段内每个产品类型的工单数量 子单
                case "28":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhref", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    sqlstr = "select B.product_name as 产品类型,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Product as B where A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.product_id=B.product_id GROUP BY B.product_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个产品类型的工单数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;

                    sqlstr = "select C.product_name as 产品类型,COUNT(cast(A.order_record_id as varchar(40))) as 子单数量 into #T from Table_Order_record as A,Table_Product as C,Table_Work_order as B where A.request_time between '" +
                             txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.order_id=B.order_id and B.product_id=C.product_id GROUP BY C.product_name;" +
                             "select * from #T union select '合计',SUM(子单数量) from #T order by 子单数量;drop table #T;";
                    dt2 = new DbHelper().Query(sqlstr).Tables[0];
                    GridView2.DataSource = dt2;
                    GridView2.DataBind();
                    hidTitle2.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个产品类型的子单数量";
                    ZedGraphWeb3.RenderGraph += OnRenderGraph3;
                    ZedGraphWeb3.Visible = true;
                    ZedGraphWeb4.RenderGraph += OnRenderGraph4;
                    ZedGraphWeb4.Visible = true;
                    palChild.Visible = true;
                    break;
                #endregion

                #region 29 统计某时段内某工单状态的每个镇区的工单数量
                case "29":
                    if (string.IsNullOrEmpty(txtSTART_DATE.Value) || string.IsNullOrEmpty(txtEND_DATE.Value))
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wndowhr", "<script type='text/javascript'>alert('请选择时间段！');</script>");
                        return;
                    }
                    if (ddlOrderState.SelectedValue == "0")
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "wdowhef", "<script type='text/javascript'>alert('请选择工单状态！');</script>");
                        return;
                    }
                    sqlstr = "select B.town_name as 镇区,COUNT(cast(A.order_id as varchar(40))) as 工单数量 into #T from Table_Work_order as A ,Table_Town as B where A.order_status='" + ddlOrderState.SelectedValue + "' and A.task_time between '" +
                                    txtSTART_DATE.Value + " 0:0:0' and '" + txtEND_DATE.Value + " 23:59:59' and A.town_id=B.town_id GROUP BY B.town_name;"
                                    + "select * from #T union select '合计',SUM(工单数量) from #T order by 工单数量;drop table #T;";
                    dt = new DbHelper().Query(sqlstr).Tables[0];
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    hidTitle.Value = txtSTART_DATE.Value + " -- " + txtEND_DATE.Value + " 每个镇区的" + ddlOrderState.SelectedItem.Text + "工单的数量";
                    ZedGraphWeb1.RenderGraph += OnRenderGraph1;
                    ZedGraphWeb1.Visible = true;
                    ZedGraphWeb2.RenderGraph += OnRenderGraph2;
                    ZedGraphWeb2.Visible = true;
                    palChild.Visible = false;
                    break;
                #endregion
            }
        }

        /// <summary>
        /// 折线图
        /// </summary>
        /// <param name="zgw"></param>
        /// <param name="g"></param>
        /// <param name="masterPane"></param>
        private void OnRenderGraph1(ZedGraphWeb zgw, Graphics g, ZedGraph.MasterPane masterPane)
        {
            if (dt != null)
            {
                GraphPane myPane = masterPane[0];

                myPane.Title.Text = hidTitle.Value;
                //myPane.XAxis.Title.Text = "时间（秒）";
                myPane.YAxis.Title.Text = "工单数量";

                PointPairList list = new PointPairList();
                string[] labels = new string[dt.Rows.Count - 1];
                
                for (double x = 0; x < dt.Rows.Count - 1; x += 1.0)
                {
                    double y = Convert.ToDouble(dt.Rows[Convert.ToInt32(x)][1]);
                    labels.SetValue(dt.Rows[Convert.ToInt32(x)][0].ToString(), Convert.ToInt32(x));
                    list.Add(x, y);
                }

                // Add a curve
                LineItem curve = myPane.AddCurve("", list, Color.Red, SymbolType.Circle);
                curve.Line.Width = 2.0F;
                curve.Line.IsSmooth = true;
                curve.Line.SmoothTension = 0.3F;
                curve.Line.IsAntiAlias = true;
                curve.Line.Fill = new Fill(Color.White, Color.FromArgb(255, Color.SkyBlue), 45.0F);
                curve.Symbol.Fill = new Fill(Color.White);
                curve.Symbol.Size = 7;
                myPane.XAxis.MajorTic.IsBetweenLabels = true;
                myPane.XAxis.Scale.TextLabels = labels;
                myPane.XAxis.Type = AxisType.Text;
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F);
                myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
                masterPane.AxisChange(g);
            }
        }

        private void OnRenderGraph3(ZedGraphWeb zgw, Graphics g, ZedGraph.MasterPane masterPane)
        {
            if (dt != null)
            {
                GraphPane myPane = masterPane[0];

                myPane.Title.Text = hidTitle2.Value;
                //myPane.XAxis.Title.Text = "时间（秒）";
                myPane.YAxis.Title.Text = "工单数量";

                PointPairList list = new PointPairList();
                string[] labels = new string[dt2.Rows.Count - 1];

                for (double x = 0; x < dt2.Rows.Count - 1; x += 1.0)
                {
                    double y = Convert.ToDouble(dt2.Rows[Convert.ToInt32(x)][1]);
                    labels.SetValue(dt2.Rows[Convert.ToInt32(x)][0].ToString(), Convert.ToInt32(x));
                    list.Add(x, y);
                }

                // Add a curve
                LineItem curve = myPane.AddCurve("", list, Color.Red, SymbolType.Circle);
                curve.Line.Width = 2.0F;
                curve.Line.IsSmooth = true;
                curve.Line.SmoothTension = 0.3F;
                curve.Line.IsAntiAlias = true;
                curve.Line.Fill = new Fill(Color.White, Color.FromArgb(255, Color.SkyBlue), 45.0F);
                curve.Symbol.Fill = new Fill(Color.White);
                curve.Symbol.Size = 7;
                myPane.XAxis.MajorTic.IsBetweenLabels = true;
                myPane.XAxis.Scale.TextLabels = labels;
                myPane.XAxis.Type = AxisType.Text;
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F);
                myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
                masterPane.AxisChange(g);
            }
        }

        /// <summary>
        /// 柱状图
        /// </summary>
        /// <param name="zgw"></param>
        /// <param name="g"></param>
        /// <param name="masterPane"></param>
        private void OnRenderGraph2(ZedGraphWeb zgw, Graphics g, ZedGraph.MasterPane masterPane)
        {
            if (dt != null)
            {
                GraphPane myPane = masterPane[0];

                myPane.Title.Text = hidTitle.Value;
                myPane.YAxis.Title.Text = "工单数量";

                PointPairList list = new PointPairList();
                string[] labels = new string[dt.Rows.Count - 1];

                for (double x = 0; x < dt.Rows.Count - 1; x += 1.0)
                {
                    double y = Convert.ToDouble(dt.Rows[Convert.ToInt32(x)][1]);
                    labels.SetValue(dt.Rows[Convert.ToInt32(x)][0].ToString(), Convert.ToInt32(x));
                    list.Add(x, y);
                }

                BarItem myCurve = myPane.AddBar("", list, Color.Blue);
                myCurve.Bar.Fill = new Fill(Color.SkyBlue, Color.White, Color.SkyBlue);
                myPane.BarSettings.Type = BarType.Stack;
                myPane.XAxis.MajorTic.IsBetweenLabels = true;
                myPane.XAxis.Scale.TextLabels = labels;
                myPane.XAxis.Type = AxisType.Text;
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F);
                myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
                masterPane.AxisChange(g);
            }
        }

        private void OnRenderGraph4(ZedGraphWeb zgw, Graphics g, ZedGraph.MasterPane masterPane)
        {
            if (dt != null)
            {
                GraphPane myPane = masterPane[0];

                myPane.Title.Text = hidTitle2.Value;
                myPane.YAxis.Title.Text = "工单数量";

                PointPairList list = new PointPairList();
                string[] labels = new string[dt2.Rows.Count - 1];

                for (double x = 0; x < dt2.Rows.Count - 1; x += 1.0)
                {
                    double y = Convert.ToDouble(dt2.Rows[Convert.ToInt32(x)][1]);
                    labels.SetValue(dt2.Rows[Convert.ToInt32(x)][0].ToString(), Convert.ToInt32(x));
                    list.Add(x, y);
                }

                BarItem myCurve = myPane.AddBar("", list, Color.Blue);
                myCurve.Bar.Fill = new Fill(Color.SkyBlue, Color.White, Color.SkyBlue);
                myPane.BarSettings.Type = BarType.Stack;
                myPane.XAxis.MajorTic.IsBetweenLabels = true;
                myPane.XAxis.Scale.TextLabels = labels;
                myPane.XAxis.Type = AxisType.Text;
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F);
                myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
                masterPane.AxisChange(g);
            }
        }

        protected void gvReport_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >= 0)
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor,this.style.background='#ffe3a0'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#fff'");
            }
        }        
    }
}
